With oIni
.ConfigName = Trim$(txtConfig)
.Section = Trim$(txtSection) astrKeys = .SectionGet End With
lstKeys.Clear For intLoop = 0 To UBound(astrKeys)
lstKeys.AddItem astrKeys(intLoop)
Next
Set oIni = Nothing
End Sub
The SectionGet() Method in the INI Class
The SectionGet() method accepts an optional argument of which section to get keys from. Because youll be retrieving many values, the strBuffer variable is filled with 2,048 spaces prior to the call to GetPrivateProfileSection().
The value thats filled into the strBuffer variable is a Chr(0)-delimited string with all the KeyName=KeyValue pairs in between. Heres an example:
Path=D:\Train\Database|File=Employees.mdb
The vertical bar (|) in this line of code represents Chr(0). Therefore, once you have this string in memory, you need to create a Variant array of each of the keyed pairs. You can do this with the new Split() function in Visual Basic 6. Pass the string and the delimiter to the Split() function, and it returns to you a Variant array. Each value in between the delimiters is an element of that array. Heres an example:
Public Function SectionGet( _
Optional strSection As String = "") _
As Variant
Dim lngRet As Long
Dim strBuffer As String
If strSection <> "" Then
mstrSection = strSection
End If